From a7423e676564829c1452e13b45241b8a2a096313 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 23 Sep 2014 22:14:02 -0700 Subject: [PATCH] Add a test for #432 All problems have been fixed in the previous commits, and this now closes #432 --- src/cargo/ops/cargo_rustc/mod.rs | 2 -- tests/test_cargo_compile_path_deps.rs | 18 ++++-------- tests/test_cargo_cross_compile.rs | 3 +- tests/test_cargo_test.rs | 42 +++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 6a5067376..4260ab34f 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -11,8 +11,6 @@ use util::{Config, internal, ChainError, Fresh, profile}; use self::job::{Job, Work}; use self::job_queue as jq; use self::job_queue::JobQueue; -use self::context::{Context, PlatformRequirement, PlatformTarget}; -use self::context::{PlatformPlugin, PlatformPluginAndTarget}; pub use self::compilation::Compilation; pub use self::context::Context; diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 583289cc6..272345575 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -712,7 +712,10 @@ test!(dev_deps_no_rebuild_lib { name = "foo" doctest = false "#) - .file("src/lib.rs", "") + .file("src/lib.rs", r#" + #[cfg(test)] extern crate bar; + #[cfg(not(test))] fn foo() { env!("FOO"); } + "#) .file("bar/Cargo.toml", r#" [package] @@ -722,20 +725,11 @@ test!(dev_deps_no_rebuild_lib { "#) .file("bar/src/lib.rs", "pub fn bar() {}"); p.build(); - assert_that(p.process(cargo_dir().join("cargo")).arg("build"), + assert_that(p.process(cargo_dir().join("cargo")).arg("build") + .env("FOO", Some("bar")), execs().with_status(0) .with_stdout(format!("{} foo v0.5.0 ({})\n", COMPILING, p.url()))); - p.root().move_into_the_past().assert(); - - // Now that we've built the library, it *should not* be built again as part - // of `cargo test`, even if we have some dev dependencies that weren't - // previously built. - File::create(&p.root().join("src/lib.rs")).write_str(r#" - #[cfg(test)] extern crate bar; - #[cfg(not(test))] fn foo() { bar(); } - "#).unwrap(); - p.root().join("src/lib.rs").move_into_the_past().assert(); assert_that(p.process(cargo_dir().join("cargo")).arg("test"), execs().with_status(0) diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index 1f06e35d0..cc5745b0d 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -1,7 +1,6 @@ // Currently the only cross compilers available via nightlies are on linux/osx, // so we can only run these tests on those platforms -#![cfg(target_os = "linux")] -#![cfg(target_os = "macos")] +#![cfg(any(target_os = "linux", target_os = "macos"))] use std::os; use std::path; diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 0d164c8b8..e739f3463 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -983,3 +983,45 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n ", compiling = COMPILING, running = RUNNING, dir = p.url()).as_slice())); }) + +test!(almost_cyclic_but_not_quite { + let p = project("a") + .file("Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [dev-dependencies.b] + path = "b" + [dev-dependencies.c] + path = "c" + "#) + .file("src/lib.rs", r#" + #[cfg(test)] extern crate b; + #[cfg(test)] extern crate c; + "#) + .file("b/Cargo.toml", r#" + [package] + name = "b" + version = "0.0.1" + authors = [] + + [dependencies.a] + path = ".." + "#) + .file("b/src/lib.rs", r#" + extern crate a; + "#) + .file("c/Cargo.toml", r#" + [package] + name = "c" + version = "0.0.1" + authors = [] + "#) + .file("c/src/lib.rs", ""); + + assert_that(p.cargo_process("build"), execs().with_status(0)); + assert_that(p.process(cargo_dir().join("cargo")).arg("test"), + execs().with_status(0)); +}) -- 2.30.2